package com.szyjjk.controller;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.szyjjk.constants.SzyjjkConstant;
import com.szyjjk.entity.ResponseBo;
import com.szyjjk.entity.RunModelFile;
import com.szyjjk.entity.SysImageCrawler;
import com.szyjjk.service.RunModelFileService;

@Controller
@RequestMapping("/setRead")
public class RunModelFileController {
	
	@Autowired
	private RunModelFileService runModelFileService;
	
	
	@RequestMapping("/query.do")
	@ResponseBody
	public JSONObject read(HttpServletRequest request,int pageNo) {
		JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 0);
		List<RunModelFile> queryList = runModelFileService.queryList1((pageNo - 1) * 10, 50, null);

        jsonObject.put("list", queryList);
        jsonObject.put("count", runModelFileService.queryList().size());
        
		return jsonObject;
	}
	@RequestMapping("/update.do")
	@ResponseBody
	public ResponseBo update(HttpServletRequest request,RunModelFile runModelFile) {
		String userid = (String) request.getSession().getAttribute(SzyjjkConstant.TOKEN);
		runModelFile.setUpdateUser(userid);
		runModelFile.setUpdateTime(new Date());
		ResponseBo r = new ResponseBo();
		runModelFileService.update(runModelFile);
		return r;
	}
}
